<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTablePddOrders extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('ce_pdd_orders', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('goods_id')->default(0)->comment('商品id');
            $table->string('goods_name')->default(null)->comment('商品名字');
            $table->bigInteger('goods_price')->default(0)->comment('订单中sku的单件价格，单位为分');
            $table->bigInteger('goods_quantity')->default(0)->comment('购买商品的数量');
            $table->string('custom_parameters')->default(null)->comment('转链携带的自定义参数，其中包含memberId，用于后面跟单');
            $table->bigInteger('order_amount')->default(0)->comment('实际支付金额，单位为分');
            $table->bigInteger('order_pay_time')->default(0)->comment('支付时间');
            $table->string('order_sn')->default(null)->comment('订单编号')->unique();
            $table->integer('order_status')->default(0)->comment('订单状态：0-已支付；1-已成团；2-确认收货；3-审核成功；4-审核失败（不可提现）；5-已经结算 ;10-已处罚');
            $table->string('fail_reason')->default(null)->comment('订单审核失败/惩罚原因');
            $table->string('order_status_desc')->default(null)->comment('订单状态描述');
            $table->string('p_id')->default(null)->comment('推广位ID');
            $table->bigInteger('promotion_amount')->default(0)->comment('佣金金额，单位为分，订单的实际返现金额以此为准');
            $table->bigInteger('promotion_rate')->default(0)->comment('佣金比例，千分比');
            $table->bigInteger('member_id')->default(0)->comment('下单用户id，custom_parameters中携带的memberId');
            $table->string('goods_thumbnail_url', 500)->default(null)->comment('商品缩略图');
            $table->bigInteger('order_create_time')->default(0)->comment('订单生成时间');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('ce_pdd_orders');
    }
}
